<?php
session_start();
$captcha = imagecreatefromgif('img_cap.gif');

//set some variables
$black = imagecolorallocate($captcha, 3, 3, 3);
$white = imagecolorallocate($captcha, 225, 225, 225);
$red = imagecolorallocate($captcha, 225, 0, 0);
$font = 'utmdax.ttf';

//random stuff
$string = md5(microtime() * time());
$str = substr($string, 0, 6);

$_SESSION['Captcha'] = $str;

//create some stupid stuff

imagettftext($captcha, 40, 2, 90, 50, $black, $font, $str);

// begin to create image
header('content-type: image/png');
imagepng($captcha);

//clean up
imagedestroy($captcha);
?>